<?php

// Database connection
include 'includes/connect.php';
?>


    <ul class="menu collapsible"><li><a href="index.php">Home</a></li>
    <?php
    //Controleer of de ingelogde user ook admin is
    if($_SESSION['admin_check'] == '1')
    {
        echo "<li><a href='admin/index.php'>Admin panel</a></li>";
    }
    ?>
    <?php if(!empty($_SESSION['klantid'])){?>
                    <li><a href="#">Account</a>
                        <ul class="acitem">
                            <li><a href="account.php">Mijn Account</a></li>
                            <li><a href="view_wishlist.php">Wishlist</a></li>
                            <li><a href="view_stdlijst.php">Pers. lijst</a></li>
                            <li><a href="logout.php">Uitloggen</a></li>
                        </ul>
                    </li>
        <?php }?>
        <li><a href="#">Categorie&euml;n</a>
            <ul class="acitem">
                <li><a href="cat.php">Alle producten</a></li>
                <?php
                    $result = mysql_query("SELECT categorie FROM product GROUP BY categorie ORDER BY categorie ASC")
                    or die(mysql_error());


                    // keeps getting the next row until there are no more to get
                    while ($row = mysql_fetch_array($result)) {

                        $cat=$row['categorie'];

                    // Print out the contents of each row into a table
                        echo "<li><a href=\"cat.php?c=$cat\">$cat</a></li>";
                    }
                ?>
            </ul>
        </li>
        <li><ul><a href="contact.php">Contact</a></ul></li>
        <?php

          // Retrieve all the data from the table
          $result = mysql_query("SELECT * FROM page")
          or die(mysql_error());

          // keeps getting the next row until there are no more to get
          while ($row = mysql_fetch_array($result)) {

            $pn=$row['pagename'];
            $pt=$row['pagetitle'];

            // Print out the contents of each row into an unordered list
            echo "<li><a href=\"page.php?p=$pn\">$pt</a></li>";
          }

        ?>



    </ul>
<script type="text/javascript">
    // get the current page by parsing the url
    urlParts = location.href.split("/");
    if (urlParts[urlParts.length - 1].length)
    {
      currentURL = urlParts[urlParts.length - 1];
        if(currentURL=="index.php")
        {
            currentURL = "cat.php";
        }
    } else
    {
      currentURL = "cat.php";
    }

    // select the li parent of the matching a tag
    selectedPage = $("a[href='" + currentURL + "']").parent().parent().parent();
    $(selectedPage).addClass("expand");
</script>



